<include file="Public/header"/>
<include file="Public/menu"/>

<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            活动专题
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="{:U('index/index')}"><i class="fa fa-dashboard"></i> 活动专题</a></li>
            <li class="active">专题模板</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="javascript:;">专题列表</a></li>
                        <li><a href="{:U('Special/template')}">模板列表</a></li>

                        <li class="pull-right header"></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="tab_0">
                            <div class="box-header">
                                <h3 class="box-title"></h3>
                                <div class="form-inline pull-right">
                                    <form action="{:U('Special/index')}" method="get" pjax-container="">
                                        <fieldset>
                                            <div class="input-group input-group-sm">
                                                <span class="input-group-addon"><strong>专题标题</strong></span>
                                                <input type="hidden" name="search_field" value="title">
                                                <div class="input-group input-group-sm">
                                                    <input type="text" class="form-control" placeholder="搜索"
                                                           name="search" value="{$search}">
                                                </div>
                                            </div>

                                            <div class="input-group input-group-sm">
                                                <div class="input-group-btn">
                                                    <button type="submit" class="btn btn-primary"><i
                                                            class="fa fa-search"></i>
                                                    </button>
                                                </div>
                                            </div>
                                        </fieldset>
                                    </form>
                                </div>

                                <div class="btn-group pull-right" style="margin-right: 10px">
                                    <a href="{:U('Special/template')}" class="btn btn-sm btn-success"><i
                                            class="fa fa-save"></i>&nbsp;&nbsp;选用模板</a>
                                </div>

                            </div>
                            <!-- /.box-header -->
                            <div class="box">

                                <div class="box-body table-responsive no-padding">
                                    <table class="table table-hover">
                                        <tbody>
                                        <tr>
                                            <th><!--<input type="checkbox" class="grid-select-all">--></th>
                                            <th>ID<a class="fa fa-fw fa-sort"
                                                     href="{:U('Special/index',array('p'=>$p,'order_field'=>'id','order'=>$order), '')}"></a>
                                            </th>
                                            <th>专题标题</th>
                                            <th>副专题标题</th>
                                            <th>分享导读</th>
                                            <th>创建时间</th>
                                            <th>操作</th>
                                        </tr>
                                        <volist name="list" id="vo">
                                            <tr>
                                                <td>
                                                    <!--<input type="checkbox" class="grid-item" data-id="{$vo.id}">--></td>
                                                <td>{$vo.id}</td>
                                                <td>{$vo.title}</td>
                                                <td>{$vo.title2}</td>
                                                <td>{$vo.title3}</td>
                                                <td>{$vo.create_time|date="Y-m-d",###}</td>
                                                <td>
                                                    <a href="javascript:void(0);" data-id="{$vo.id}" class="btn btn-sm btn-success _view" >预览</a>
                                                    <a href="{:U('Special/edit', array('id'=>$vo['id']), '')}"
                                                       class="btn btn-sm btn-primary grid-refreshe">编辑</a>
                                                    <a href="javascript:void(0);" data-id="{$vo.id}" class="btn btn-sm btn-danger _delete">删除</a>
                                                </td>
                                            </tr>
                                        </volist>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="box-footer clearfix">
                                    <!--<input type="checkbox" class="grid-select-all">-->&nbsp;&nbsp;&nbsp;
                                    <!--<a class="btn btn-sm btn-danger batch-delete">批量删除</a>-->
                                    <a class="btn btn-sm btn-primary grid-refresh"><i class="fa fa-refresh"></i></a>
                                    {$page}
                                </div>
                                <!-- /.box-body -->
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>
<script src="/Public/layer/layer.js"></script>
<script data-exec-on-popstate>

    $(function () {

        $('.grid-select-all').change(function () {
            if (this.checked) {
                $('.grid-item').prop("checked", true);
            } else {
                $('.grid-item').prop("checked", false);
            }
        });

        $('._delete').click(function () {
            if (!confirm("确认删除")) {
                return false;
            }
            var id = $(this).attr('data-id');
            if (id) {
                $.ajax({
                    type: "POST",
                    url: "{:U('Special/del')}",
                    data: {id: id},
                    success: function (msg) {
                        alert(msg.message);
                        window.location.reload();
                    },
                    error: function (msg) {
                        alert(msg.message);
                    }
                });
            }
        });

        $('.batch-delete').on('click', function (e) {
            if (!confirm("确认批量删除")) {
                return false;
            }
            var data = [];
            $(".grid-item[type='checkbox']:checked").each(function (i) {
                var id = $(this).attr('data-id');
                data.push(id);
                //$(this).parent().parent().remove();
            });
            if (data) {
                $.ajax({
                    type: "POST",
                    url: "{:U('Special/del')}",
                    data: {id: data},
                    success: function (msg) {
                        console.log(msg.message);
                    },
                    error: function (msg) {
                        alert(msg.message);
                    }
                });
            }
        });

        $('._view').click(function () {
            var id = $(this).attr('data-id');
            layer.open({
                type: 2,
                title: '模板预览 手机页',
                shadeClose: true,
                shade: 0.8,
                area: ['380px', '90%'],
                content: "{:U('Qgs/Special/viewSpecial/id/"+id+"')}", //iframe的url
            });
        });

    });
</script>